package com.zhiguang.cms.dao;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.zhiguang.cms.entity.Link;

public interface LinkMapper {
	// 添加一个友情链接 
	/*private String url       ;// 链接的地址
	private String name      ; // 链接的名称
	private Date created   ;// 创建的时间
	*/
	@Insert("INSERT INTO cms_link(url,name,created) VALUES(#{url},#{name},now()) ")
	int add(Link link);
	
	// 修改
	@Update("UPDATE cms_link SET url=#{url} ,name=#{name} WHERE id=#{id}")
	int update(Link link);
	
	/**
	 * 批量删除
	 * @param id
	 * @return
	 */
	int deleteBatch(@Param("ids") int[] ids);
	
	/**
	 * 根据Id删除
	 * @param id
	 * @return
	 */
	@Delete("DELETE FROM cms_link WHERE id=#{id}")
	int delete(@Param("id") int id);
	
	
	/**
	 * 查询
	 * @return
	 */
	@Select("SELECT id,url,name,created FROM cms_link ORDER BY id DESC ")
	List<Link> list();

	/**
	 * 
	 * @param id
	 * @return
	 */
	@Select("SELECT id,url,name,created FROM cms_link  WHERE id=#{value}")
	Link find(int id);
	
}
